<?php
    @include_once("./conn.php");

    $id = $_POST["id"];
    

    if(!($id)){
        argErr();
    }


    
    $search = "select * from `shoppingcar` where id = '$id'";
    $result = mysqli_query($conn,$search);

    $item = mysqli_fetch_assoc($result);  // 查询的结果

    if($item){   
        $sql = "update `shoppingcar` set buyNum = buyNum + 1 where id = '$id'";
    }
    mysqli_query($conn,$sql);   //执行sql

   
    $rows = mysqli_affected_rows($conn);

    $obj = array();
    if($rows>0){
        $obj["status"] = true;
        $obj["detail"] = "商品数量+1";
    }else{
        $obj["status"] = false;
        $obj["detail"] = "商品数量增加失败";
        $obj["sql"] = $sql;
    }
    echo json_encode($obj);
?>